package chapter19.homework3;
import java.util.ArrayList;

public class Client {
    public static void main(String[] args) {
        ArrayList<Object> homepages = new ArrayList<>();
        homepages.add("水浒传");
        homepages.add("西游记");
        homepages.add("红楼梦");
        homepages.add("三国演义");

        AbstractObjectList abstractObjectList;
        AbstractIterator abstractIterator;

        abstractObjectList = new HomepageList(homepages);//创建聚合对象...
        abstractIterator  = abstractObjectList.createI();//创建迭代对象.....

        System.out.println("当前页面内容为：.....");
        while (!abstractIterator.isLast()) {//诺当前不是遍历的最后的元素
            System.out.println(abstractIterator.getPreviousItem() + ",");
            abstractIterator.next();//继续进行遍历...
        }

        System.out.println();
        System.out.println("=======================");
        System.out.println("上一级的页面内容为：....");

        while (!abstractIterator.isFirst()) {//诺当前不是遍历的第一的元素
            System.out.println(abstractIterator.getPreviousItem() + ",");
            abstractIterator.previous();
        }
    }
}
